import {createRouter, createWebHashHistory} from 'vue-router'

const Login = () => import('@/views/login/index.vue')
const LoginCallback = () => import('@/views/login/callback/index.vue')
const Layout = () => import('@/views/Layout.vue')
const Home = () => import('@/views/home/index.vue')
const Category = () => import('@/views/category/index.vue')
const BreadCrumbLayout = () => import('@/views/BreadCrumbLayout.vue')
const CategorySub = () => import('@/views/category/sub/index.vue')
const GoodDetail = () => import('@/views/goods/index.vue')
const Cart = () => import('@/views/cart/index.vue')
const Pay = () => import('@/views/cart/pay/index.vue')
const PayPage = () => import('@/views/cart/pay/payPage/index.vue')

const router = createRouter({
  history: createWebHashHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      component: Layout,
      children: [
        {path: '', component: Home},
        {
          path: '',
          component: BreadCrumbLayout,
          children: [
            {path: 'category/:id', component: Category},
            {path: '/category/sub/:id', component: CategorySub},
            {path: '/product/:id', component: GoodDetail},
            {path: '/cart', component: Cart},
            {path: '/cart/pay', component: Pay},
            {path: '/cart/pay/pay_page', component: PayPage}
          ]
        }
      ]
    },
    {path: '/login', component: Login},
    {path: '/login/callback', component: LoginCallback}
  ],
  scrollBehavior: () => ({top: 0, left: 0})
})

export default router
